home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-ARM / DMA.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  141 lines

  1. #ifndef __ASM_ARM_DMA_H
  2. #define __ASM_ARM_DMA_H
  3.  
  4. typedef unsigned int dmach_t;
  5.  
  6. #include <linux/config.h>
  7. #include <linux/kernel.h>
  8. #include <asm/irq.h>
  9. #include <asm/system.h>
  10. #include <asm/spinlock.h>
  11. #include <asm/arch/dma.h>
  12.  
  13. /*
  14.  * DMA modes - we have two, IN and OUT
  15.  */
  16. typedef unsigned int dmamode_t;
  17.  
  18. #define DMA_MODE_MASK    1
  19.  
  20. #define DMA_MODE_READ    0
  21. #define DMA_MODE_WRITE    1
  22. #define DMA_AUTOINIT    2
  23.  
  24. typedef struct {
  25.     unsigned long address;
  26.     unsigned long length;
  27. } dmasg_t;
  28.  
  29. extern const char dma_str[];
  30.  
  31. extern spinlock_t  dma_spin_lock;
  32.  
  33. extern __inline__ unsigned long claim_dma_lock(void)
  34. {
  35.     unsigned long flags;
  36.     spin_lock_irqsave(&dma_spin_lock, flags);
  37.     return flags;
  38. }
  39.  
  40. extern __inline__ void release_dma_lock(unsigned long flags)
  41. {
  42.     spin_unlock_irqrestore(&dma_spin_lock, flags);
  43. }
  44.  
  45. /* Clear the 'DMA Pointer Flip Flop'.
  46.  * Write 0 for LSB/MSB, 1 for MSB/LSB access.
  47.  *
  48.  * NOTE: This is an architecture specific function, and should
  49.  *       be hidden from the drivers.
  50.  */
  51. #define clear_dma_ff(channel)
  52.  
  53. /* Set only the page register bits of the transfer address.
  54.  *
  55.  * NOTE: This is an architecture specific function, and should
  56.  *       be hidden from the drivers
  57.  */
  58. extern __inline__ void set_dma_page(dmach_t channel, char pagenr)
  59. {
  60.     printk(dma_str, "set_dma_page", channel);
  61. }
  62.  
  63. /* Request a DMA channel
  64.  *
  65.  * Some architectures may need to do allocate an interrupt
  66.  */
  67. extern int  request_dma(dmach_t channel, const char * device_id);
  68.  
  69. /* Free a DMA channel
  70.  *
  71.  * Some architectures may need to do free an interrupt
  72.  */
  73. extern void free_dma(dmach_t channel);
  74.  
  75. /* Enable DMA for this channel
  76.  *
  77.  * On some architectures, this may have other side effects like
  78.  * enabling an interrupt and setting the DMA registers.
  79.  */
  80. extern void enable_dma(dmach_t channel);
  81.  
  82. /* Disable DMA for this channel
  83.  *
  84.  * On some architectures, this may have other side effects like
  85.  * disabling an interrupt or whatever.
  86.  */
  87. extern void disable_dma(dmach_t channel);
  88.  
  89. /* Set the DMA scatter gather list for this channel
  90.  *
  91.  * This should not be called if a DMA channel is enabled,
  92.  * especially since some DMA architectures don't update the
  93.  * DMA address immediately, but defer it to the enable_dma().
  94.  */
  95. extern void set_dma_sg(dmach_t channel, dmasg_t *sg, int nr_sg);
  96.  
  97. /* Set the DMA address for this channel
  98.  *
  99.  * This should not be called if a DMA channel is enabled,
  100.  * especially since some DMA architectures don't update the
  101.  * DMA address immediately, but defer it to the enable_dma().
  102.  */
  103. extern void set_dma_addr(dmach_t channel, unsigned long physaddr);
  104.  
  105. /* Set the DMA byte count for this channel
  106.  *
  107.  * This should not be called if a DMA channel is enabled,
  108.  * especially since some DMA architectures don't update the
  109.  * DMA count immediately, but defer it to the enable_dma().
  110.  */
  111. extern void set_dma_count(dmach_t channel, unsigned long count);
  112.  
  113. /* Set the transfer direction for this channel
  114.  *
  115.  * This should not be called if a DMA channel is enabled,
  116.  * especially since some DMA architectures don't update the
  117.  * DMA transfer direction immediately, but defer it to the
  118.  * enable_dma().
  119.  */
  120. extern void set_dma_mode(dmach_t channel, dmamode_t mode);
  121.  
  122. /* Get DMA residue count. After a DMA transfer, this
  123.  * should return zero. Reading this while a DMA transfer is
  124.  * still in progress will return unpredictable results.
  125.  * If called before the channel has been used, it may return 1.
  126.  * Otherwise, it returns the number of _bytes_ left to transfer.
  127.  */
  128. extern int  get_dma_residue(dmach_t channel);
  129.  
  130. #ifndef NO_DMA
  131. #define NO_DMA    255
  132. #endif
  133.  
  134. #ifdef CONFIG_PCI_QUIRKS
  135. extern int isa_dma_bridge_buggy;
  136. #else
  137. #define isa_dma_bridge_buggy    (0)
  138. #endif
  139.  
  140. #endif /* _ARM_DMA_H */
  141.